from exts import mail
from flask_mail import Message
from celery_tasks import cel

@cel.task
def do_send_mail(email=None, captcha=None):
    print("任务开始", email, captcha)
    if captcha and email:
        msg = Message(
            subject="任务悬赏系统验证码",  # 邮件主题
            recipients=[email],  # 收件人
            body= "【任务悬赏系统发送】\n您的验证码是: '{}' , \n验证码将会在5分钟后失效，请尽快输入".format(captcha),  # 内容
        )
        mail.send(msg)
        return {"email": email, "captcha": captcha}
    else:
        return "任务失败，没有获取邮箱或者验证码"

